<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script language="JavaScript" src="${pageContext.request.contextPath}/Js/jquery-1.7.2.js"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/Css/Admin.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/Css/bootstrap.min.css">
    <script language="JavaScript" src="${pageContext.request.contextPath}/Js/Func.js"></script>
<%--
    <script language="JavaScript" src="${pageContext.request.contextPath}/Js/question/question.js"></script>
--%>
    <script>
        function edit(id) {
            var postData="id="+id+"&optiona="+$.trim($("#Answer1").val())+
                "&optionb="+$.trim($("#Answer2").val())+
                "&optionc="+$.trim($("#Answer3").val())+
                "&optiond="+$.trim($("#Answer4").val());

            $.post(
                "/admin/question/edit",
                postData,
                function (data) {
                    if(data.code==200){
                        alert("编辑成功");
                        /*document.getElementById("Answer1").value="";
                        document.getElementById("Answer2").value="";
                        document.getElementById("Answer3").value="";
                        document.getElementById("Answer4").value="";*/
                        window.history.go(-1);

                    }else{
                        alert("编辑失败");
                    }

                },"json"
            )
        }
    </script>
</head>
<body>
<div class=nav><a href=admin_main.jsp>桌面</a>»管理员添加
</div>
<div id="admin_surveyAdd_main">
    <table class=table cellspacing="0" cellpadding="0">
        <tr>
            <th>编辑题目</th>
            <th></th>
            <th></th>
        </tr>
        <tr>
            <td>题型：</td>
            <td>
                <c:if test="${question.type==1}">
                    <input name="Question_type" id="qtype_dx" type="radio" value="1" checked>单选题
                </c:if>
                <c:if test="${question.type==2}">
                    <input name="Question_type" type="radio" value="2" checked>多选题
                </c:if>
            </td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </table>
    <form name="form1">
        <input id="id" hidden value="${question.id}">
        问题：<input name="qHead" value="${question.head}" type="text" size="40">
        <br/><br/>
        备选项：
        <ul type="1" id="ulAnswer1">
            <li><input type="radio"><input type="text" id="Answer1" name="Answer" value="${answer.optiona}"></li>
            <li><input type="radio"><input type="text" id="Answer2" name="Answer" value="${answer.optionb}"></li>
            <li><input type="radio"><input type="text" id="Answer3" name="Answer" value="${answer.optionc}"></li>
            <li><input type="radio"><input type="text" id="Answer4" name="Answer" value="${answer.optiond}"></li>
        </ul>
        <div id="button1">
            <input type="button"  value="编辑题目" onclick="edit(${question.id})" >
        </div>
    </form>
</div>
</div>

</body>
</html>


<%--____________________________________________________________________________--%>
<%--____________________________________________________________________________--%>
<%--____________________________________________________________________________--%>


<%--
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
&lt;%&ndash;<%@ page import="com.iWen.survey.dao.DAOFactory"%>
<%@ page import="com.iWen.survey.dto.Question" %>
<%@ page import="com.iWen.survey.dao.QuestionDAO" %>
<%
	QuestionDAO dao=DAOFactory.getQuestionDAO();
	Question question=dao.findQuestion(Long.valueOf(request.getParameter("qid")));
%>&ndash;%&gt;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>My JSP 'SurveyAudi.jsp' starting page</title>
    <link rel="stylesheet" type="text/css" href="../Css/Admin.css">
    <script language="JavaScript" src="${pageContext.request.contextPath}/Js/jquery-1.7.2.js"></script>
    <script type="text/javascript" src="../Js/Func.js"></script>
    <script language="javascript">window.onload = tableFix;</script>
    <script type="text/javascript" src="../Js/QuestAdd.js"></script>
    <script type="text/javascript">
        function showType(typecode) {
            document.getElementById("qEditor").innerHTML = document.getElementById(typecode).innerHTML;
        }

        function MoreAnswer(type) {
            switch (type) {
                case "DX":
                case "FX":
                    var ul = document.getElementById("ulAnswer");
                    var inputTitle = document.createElement("input");
                    if (type == "DX") {
                        inputTitle.setAttribute("type", "radio");
                    } else {
                        inputTitle.setAttribute("type", "checkbox");
                    }
                    var input = document.createElement("input");
                    var li = document.createElement("li");
                    input.setAttribute("id", "Answer");
                    li.appendChild(inputTitle);
                    li.appendChild(input);
                    ul.appendChild(li);
                    break;
            }
        }
    </script>
</head>
<body>
<table class=table cellspacing="0" cellpadding="0">
    <tr>
        <th>查看题目</th>
        <th></th>
        <th></th>
    </tr>
    <tr>
        <td>选择题型：</td>
        <td>
            <input name="Question_type" id="qtype_dx" type="radio" value="1" &lt;%&ndash;onClick="showType('dx');"&ndash;%&gt;>单选题
            <input name="Question_type" id=qtype_fx type="radio" value="2" &lt;%&ndash;onClick="showType('fx');"&ndash;%&gt;>多选题
        </td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
    </tr>
</table>
<div id=qEditor></div>
<div id=dx style="display: none">
    <form name="form1" action="" method="post">
        &lt;%&ndash;<input type="hidden" value=<%=request.getParameter("sid") %>  name="sid">
        <input type="hidden" value="" name="qBody" id="qBody">
        <input type="hidden" value="" name=qResult id="qResult">&ndash;%&gt;
        问题：<input name="qHead" type="text" size="40">
        <br/><br/>
        备选项：
        <ul type="1" id="ulAnswer">
            <li>
                <input type="radio">
                <input type="text" name="Answer">
            </li>
        </ul>
        <div id="button">
            <input type="button" onclick="javascript:history.back();" value="返回">
        </div>
    </form>
</div>
<div id=fx style="display: none">
    <form name="form1" action="" method="post">
        <input type="hidden" value=<%=request.getParameter("sid") %>  name="sid">
        <input type="hidden" value="" name="qBody" id="qBody">
        <input type="hidden" value="" name=qResult id="qResult">
        问题：<input name="qHead" type="text" size="40">
        <br/><br/>
        备选项：
        <ul type="1">
            <li><input type="checkbox"><input type="text" name="Answer"></li>
            <li><input type="checkbox"><input type="text" name="Answer"></li>
            <li><input type="checkbox"><input type="text" name="Answer"></li>
            <li><input type="checkbox"><input type="text" name="Answer"></li>
        </ul>
        <div>
            <input type="button" onclick="javascript:history.back();" value="返回">
        </div>
    </form>
</div>
<script type="text/javascript">

</script>
</body>
</html>
--%>
